TEGetOffset
TEGetOffset
Obtain a character offset associated with a screen point Point thePt; in local coordinates; usually a mouseDown Point returns an offset within the data at TERec.hText TEGetOffset returns an offset which you can use to identify the character associated with a point on the screen. This works with both types of
edit record.
thePt is the point, in local coordinates. It is usually a value obtained from
hTE is a handle obtained via TENew (old style TextEdit record) or TEStylNew (new style TextEdit record). It leads to a variable-length TERec structure and identifies the edit record of interest.
Returns: a short; an offset within the edit record's text of the character that is currently drawn at thePt.
mouseDown. Thus, you can "micro-manage" the functions usually performed
by TEClick or TEKey, et al. The following code uses this offset to replace the character at a mouse click:
short theOffset;
CharsHandle theChars;
char *cp;
cp = *theChars;
cp[theOffset]='X';
InvalRect( &(*hTE)->viewRect ); /* way to force redraw */ TEGetOffset works for old-format as well as new-format edit records. associated with a particular character).